package luweiteng.demoForLogin.common.utils;

import lombok.extern.slf4j.Slf4j;
import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

@Slf4j
public class TokenUtils {

    public static String getToken(){
        String s = UUID.randomUUID().toString().replace("-", "") + "";
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            byte[] digest1 = digest.digest(s.getBytes());
            BASE64Encoder encoder = new BASE64Encoder();
            String encode = encoder.encode(digest1);
            return encode;
        } catch (NoSuchAlgorithmException e) {
           log.error("Token 生成失败！");
        }

        return null;

    }
}
